Skip to content

gh-148144: Initialize visited on copied interpreter frames#148143

Merged
pablogsal merged 1 commit intopython:mainfrom
pablogsal:bad_frame
Apr 5, 2026
Merged

gh-148144: Initialize visited on copied interpreter frames#148143
pablogsal merged 1 commit intopython:mainfrom
pablogsal:bad_frame

Conversation

@pablogsal
Copy link
Copy Markdown
Member

@pablogsal pablogsal commented Apr 5, 2026

_PyFrame_Copy() copied interpreter frames into generator and
frame-object storage without initializing the visited byte. Incremental
GC later reads frame->visited in mark_stacks() on non-start passes, so
copied frames could expose an uninitialized value once they became live
on a thread stack again.

Reset visited when copying a frame so copied frames start with defined
GC bookkeeping state. Preserve lltrace in Py_DEBUG builds.

_PyFrame_Copy() copied interpreter frames into generator and
frame-object storage without initializing the visited byte. Incremental
GC later reads frame->visited in mark_stacks() on non-start passes, so
copied frames could expose an uninitialized value once they became live
on a thread stack again.

Reset visited when copying a frame so copied frames start with defined
GC bookkeeping state. Preserve lltrace in Py_DEBUG builds.
@pablogsal pablogsal changed the title Initialize visited on copied interpreter frames gh-148144: Initialize visited on copied interpreter frames Apr 5, 2026
@gpshead gpshead added the needs backport to 3.14 bugs and security fixes label Apr 5, 2026
@pablogsal pablogsal merged commit fbfc6cc into python:main Apr 5, 2026
60 checks passed
@pablogsal pablogsal deleted the bad_frame branch April 5, 2026 23:23
@miss-islington-app
Copy link
Copy Markdown

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 5, 2026
…honGH-148143)

_PyFrame_Copy() copied interpreter frames into generator and
frame-object storage without initializing the visited byte. Incremental
GC later reads frame->visited in mark_stacks() on non-start passes, so
copied frames could expose an uninitialized value once they became live
on a thread stack again.

Reset visited when copying a frame so copied frames start with defined
GC bookkeeping state. Preserve lltrace in Py_DEBUG builds.
(cherry picked from commit fbfc6ccb0abf362a0ecdc02cd0aa2d16c1a4ce44)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 5, 2026

GH-148147 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Apr 5, 2026
pablogsal added a commit that referenced this pull request Apr 5, 2026
…-148143) (#148147)

gh-148144: Initialize visited on copied interpreter frames (GH-148143)

_PyFrame_Copy() copied interpreter frames into generator and
frame-object storage without initializing the visited byte. Incremental
GC later reads frame->visited in mark_stacks() on non-start passes, so
copied frames could expose an uninitialized value once they became live
on a thread stack again.

Reset visited when copying a frame so copied frames start with defined
GC bookkeeping state. Preserve lltrace in Py_DEBUG builds.
(cherry picked from commit fbfc6cc)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants